import React, { Component } from 'react'

export default class Arr extends Component {
    constructor () {
        super();
        this.state = {
            list: [1, 2, 3, 4],
            arr: [{ id: 1 }, { id: 2 }, { id: 3 }],
        };
    }
    render() {
        let result = this.state.arr.map((item) => {
            return <div key={item.id}><span>{item.id}</span></div>
        })

        let result2 = [];//声明一个集合
        for (let i = 0; i < this.state.arr.length; i++) {
            let item = this.state.arr[i];//对象
            result2.push(<div key={item.id}><span>{item.id}</span></div>
            )
        }
        return (
            <div>
                <h3>数组</h3>
                {this.state.list}
                {result}
                <ul>
                    {this.state.arr.map(item => <li key={item.id}>{item.id}</li>)}

                </ul>
                {result2}
            </div>
        );
    }
}

